<?php

namespace AionEh\CalculatorBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
    public function indexAction()
    {
        
        return $this->render('AionEhCalculatorBundle:Default:index.html.twig');
    }
	
	public function getScriptsAction()
	{
		$jsFiles = array(
			'js/jquery.min.js',
			'js/bootstrap.min.js',
			'js/Event.js',
			'js/Engine.js',
			'js/BuffEffect.js',
			'js/Buff.js',
			'js/BuffCollection.js',
			'js/Class.js',
			'js/Templar.js',
			'js/Monster.js',
			'js/Build.js',
			'js/Main.js'
		);
		
		$content = '';
		foreach ($jsFiles as $filename)
		{
			if (file_exists($filename))
				$content .= file_get_contents($filename);
			else
				$content .= 'console.warn("' . $filename . ' does not exist.");';
		}
		
		$response = new Response($content);
		$response->headers->set('Content-Type', 'application/javascript');
		return $response;
	}
}
